package com.hc.comm.exception;

import java.util.HashMap;
import java.util.Map;

public class BaseException extends RuntimeException {

	/**
	 * 状态码
	 */
	private int status;

	/**
	 * 状态码
	 */
	private int code;

	/**
	 * 跳转
	 */
	private String referer;

	/**
	 * 扩展参数
	 */
	private Map<Object, Object> extendMap;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public BaseException() {
	}

	public BaseException(int stauts, String message) {
		super(message);
		this.status = stauts;
	}

	public BaseException(int stauts, int code, String message) {
		super(message);
		this.status = stauts;
		this.code = code;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Map<Object, Object> getExtendMap() {
		return extendMap;
	}

	public void setExtendMap(Map<Object, Object> extendMap) {
		this.extendMap = extendMap;
	}

	public void put(Object key, Object obj) {
		if (this.extendMap == null) {
			this.extendMap = new HashMap<Object, Object>();
		}
		this.extendMap.put(key, obj);
	}

	@SuppressWarnings("unchecked")
	public <T> T get(Object key) {
		if (extendMap == null) {
			return null;
		}
		return (T) this.extendMap.get(key);
	}

	public String getReferer() {
		return referer;
	}

	public void setReferer(String referer) {
		this.referer = referer;
	}
}

